using System;
using System.Collections;
using System.IO;

namespace Wantn.Share
{
	public sealed class FileOpt
	{
		public static bool DelFile(string fileName)
		{
			bool result = false;
			try
			{
				File.Delete(fileName);
				result = true;
				return result;
			}
			catch
			{
				return result;
			}
		}

		public static bool CopyFile(string sourceFile, string destFile)
		{
			bool result = false;
			try
			{
				string directoryName = Path.GetDirectoryName(destFile);
				if (!Directory.Exists(directoryName))
				{
					Directory.CreateDirectory(directoryName);
				}
				File.Copy(sourceFile, destFile, overwrite: true);
				result = true;
				return result;
			}
			catch
			{
				return result;
			}
		}

		public static bool MoveFile(string sourceFile, string destFile)
		{
			bool result = false;
			if (CopyFile(sourceFile, destFile))
			{
				result = DelFile(sourceFile);
			}
			return result;
		}

		public static long GetFileSize(string fileName)
		{
			long result = 0L;
			try
			{
				FileInfo fileInfo = new FileInfo(fileName);
				result = fileInfo.Length;
				return result;
			}
			catch
			{
				return result;
			}
		}

		public static long GetDirSize(string path)
		{
			long result = 0L;
			try
			{
				DirectoryInfo directoryInfo_ = new DirectoryInfo(path);
				result = smethod_0(directoryInfo_);
				return result;
			}
			catch
			{
				return result;
			}
		}

		private static long smethod_0(DirectoryInfo directoryInfo_0)
		{
			long num = 0L;
			FileInfo[] files = directoryInfo_0.GetFiles();
			FileInfo[] array = files;
			foreach (FileInfo fileInfo in array)
			{
				num += fileInfo.Length;
			}
			DirectoryInfo[] directories = directoryInfo_0.GetDirectories();
			DirectoryInfo[] array2 = directories;
			foreach (DirectoryInfo directoryInfo_ in array2)
			{
				num += smethod_0(directoryInfo_);
			}
			return num;
		}

		public static bool GetAllFiles(string Dir, out string[] Files)
		{
			Files = smethod_1(Dir);
			if (Files != null && Files.Length > 0)
			{
				return true;
			}
			return false;
		}

		private static string[] smethod_1(string string_0)
		{
			try
			{
				string[] files = Directory.GetFiles(string_0);
				ArrayList arrayList = new ArrayList(files);
				string[] directories = Directory.GetDirectories(string_0);
				for (int i = 0; i < directories.Length; i++)
				{
					string[] c = smethod_1(directories[i]);
					arrayList.AddRange(c);
				}
				return (string[])arrayList.ToArray(Type.GetType("System.String"));
			}
			catch
			{
				return null;
			}
		}

	}
}
